package web;

import entity.Supplier;
import service.impl.SupplierServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/SupplierListServlet")
public class SupplierServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        SupplierServiceImpl supplierService = new SupplierServiceImpl();
        List<Supplier> suppliers = supplierService.getAllSuppliers();
        request.setAttribute("suppliers",suppliers);
        request.getRequestDispatcher("/supplier.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
